﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using Ymatou.ServiceCenter.Domain.IRepositories;
using Ymatou.ServiceCenter.Domain.Models;
using Ymatou.CommonService;

namespace Ymatou.ServiceCenter.Repository
{
    public class ServicedependencyInfoRepository : RepositoryBase<ServicedependencyInfo>,
        IServicedependencyInfoRepository
    {
        //public ServicedependencyInfo FindById(string consumerAppId, string providerAppId)
        //{
        //   return this.Find(
        //        "select * from servicedependency_info where ConsumerAppId=@ConsumerAppId AND ProviderAppId=@ProviderAppId limit 1"
        //        , new SqlParameter[]
        //        {
        //            new SqlParameter
        //            {
        //                ParameterName = "@ConsumerAppId",
        //                Value = consumerAppId,
        //                DbType = DbType.AnsiString,
        //            },
        //            new SqlParameter
        //            {
        //                ParameterName = "@ProviderAppId",
        //                Value = providerAppId,
        //                DbType = DbType.AnsiString,
        //            }
        //        }).FirstOrDefault();            
        //}

        //public int TryInsert(ServicedependencyInfo entity)
        //{
        //    try
        //    {
        //        ApplicationLog.Debug("TryInsertServicedependency_Info");    
            
        //        this.Insert("Default", "servicedependency_info", entity);
        //        return 1;
        //    }
        //    catch (MySqlException ex)
        //    {
        //        ApplicationLog.Error(string.Format("[TryInsertServicedependency_Info]异常：{0}", ex.Message), ex);
        //        if (ex.Number == 1062) return -2;
        //        return -3;
        //    }
        //    catch (Exception e)
        //    {
        //        ApplicationLog.Error(string.Format("[TryInsertServicedependency_Info]异常：{0}", e.Message), e);
        //        return -1;
        //    }          
        //}

        //public bool TryUpdate(ServicedependencyInfo entity)
        //{
        //    try
        //    {
        //        ApplicationLog.Debug("TryUpdateServicedependency_Info");
                
        //        bool updateResult = this.Update("Default", "servicedependency_info", entity);
        //        return updateResult;
        //    }
        //    catch (Exception ex)
        //    {
        //        ApplicationLog.Error(string.Format("[TryUpdateServicedependency_Info]异常：{0}", ex.Message), ex);
        //        return false;
        //    }
        //}
    }
}
